<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>IMYOURS | 企业即时通讯软件</title>

<link rel="stylesheet" href="../css/reset.css" type="text/css"
	media="screen" title="no title" />
<link rel="stylesheet" href="../css/text.css" type="text/css"
	media="screen" title="no title" />
<link rel="stylesheet" href="../css/form.css" type="text/css"
	media="screen" title="no title" />
<link rel="stylesheet" href="../css/buttons.css" type="text/css"
	media="screen" title="no title" />
<link rel="stylesheet" href="../css/grid.css" type="text/css"
	media="screen" title="no title" />
<link rel="stylesheet" href="../css/layout.css" type="text/css"
	media="screen" title="no title" />

<link rel="stylesheet"
	href="../css/ui-darkness/jquery-ui-1.8.12.custom.css" type="text/css"
	media="screen" title="no title" />
<link rel="stylesheet" href="../css/plugin/jquery.visualize.css"
	type="text/css" media="screen" title="no title" />
<link rel="stylesheet" href="../css/plugin/facebox.css" type="text/css"
	media="screen" title="no title" />
<link rel="stylesheet" href="../css/plugin/uniform.default.css"
	type="text/css" media="screen" title="no title" />
<link rel="stylesheet" href="../css/plugin/dataTables.css"
	type="text/css" media="screen" title="no title" />

<link rel="stylesheet" href="../css/custom.css" type="text/css"
	media="screen" title="no title">
<style type="text/css">
.team {
	min-height: 429px;
}

.accordion_panel {
	height: 50px;
}
</style>
</head>

<body>

	<div id="wrapper">
		<div id="top">

			<div class="content_pad">
				<ul class="right">
					<li><a href="javascript:;" class="top_icon"><span
							class="ui-icon ui-icon-person" id="useruser"></span></a></li>
					<li><a href="javascript:;" class="new_messages top_alert"
						id="unreadMsgTip"></a></li>
					<li><a href="../pages/settings.html">Settings</a></li>
					<li><a href="javascript:parent.logout();">退出登录</a></li>
				</ul>
			</div>
			<!-- .content_pad -->

		</div>
		<!-- #top -->

		<div id="header">

			<div class="content_pad">
				<h1>
					<a href="../index.html">IMYOURS</a>
				</h1>

				<ul id="nav">
					<li class="nav_icon"><a href="../index.html"><span
							class="ui-icon ui-icon-home"></span>消息中心</a></li>

					<li class="nav_dropdown nav_current nav_icon"><a
						href="friendList.html"><span
							class="ui-icon ui-icon-gripsmall-diagonal-se"></span>好友列表</a></li>

					<li class="nav_icon"><a href="companyStruct.html"><span
							class="ui-icon ui-icon-gear"></span>公司结构</a></li>
					<li class="nav_icon"><a href="admin.html"><span
							class="ui-icon ui-icon-signal"></span>管理</a></li>

					
				</ul>
			</div>
			<!-- .content_pad -->

		</div>
		<!-- #header -->

		<div id="masthead">

			<div class="content_pad">

				<h1 class="">好友列表</h1>

				<div id="bread_crumbs">
					<a href="../index.html">消息中心</a> / <a href="javascript:;"
						class="current_page">好友列表</a>
				</div>
				<!-- #bread_crumbs -->

				<div id="search">
					<form action="/search" method="get">
						<input type="text" value="" placeholder="Search" name="search"
							id="search_input" title="Search" /> <input type="submit"
							value="" name="submit" class="submit" />
					</form>
				</div>
				<!-- #search -->

			</div>
			<!-- .content_pad -->

		</div>
		<!-- #masthead -->

		<div id="content" class="xgrid">
			<div class="x9">
				<div id="contentLeft"></div>
			</div>
			<div class="x3" id="panelRight">
				<div class="accordion_container">
					<h2 class="accordion_panel">
						<a href="#">添加好友</a>
					</h2>
					<div class="accordion_content">
						<div>
							<span>好友工号</span>
						</div>
						<div>
							<input type="text" id="newTeam" />
						</div>
						<div>
							<span>加入分组</span>
						</div>
						<div>
							<select id="teamSelector"></select>
						</div>
						<div>
							<button class="btn btn-orange">添加好友</button>
						</div>
					</div>
					<h2 class="accordion_panel">
						<a href="#">添加分组</a>
					</h2>
					<div class="accordion_content">
						<div class="">
							<input type="text" id="teamInput" />
						</div>
						<div>
							<button onclick="addTeam()" class="btn btn-orange">添加分组</button>
						</div>
					</div>

				</div>

			</div>

		</div>
		<!-- #content -->

		<div id="footer">
			<div class="content_pad">
				<p>
					&copy; 2010-11 Copyright <a href="http://weibo.com/slevenc">Slevenc</a>.
					Powered by <a href="http://madebyamp.com/themes/dashboard/">Dashboard
						Admin</a>.
				</p>
			</div>
			<!-- .content_pad -->
		</div>
		<!-- #footer -->

	</div>
	<!-- #wrapper -->

	<script src="../js/jquery/jquery-1.5.2.min.js"></script>
	<script src="../js/jquery/jquery-ui-1.8.12.custom.min.js"></script>
	<script src="../js/misc/excanvas.min.js"></script>
	<script src="../js/jquery/facebox.js"></script>
	<script src="../js/jquery/jquery.visualize.js"></script>
	<script src="../js/jquery/jquery.dataTables.min.js"></script>
	<script src="../js/jquery/jquery.tablesorter.min.js"></script>
	<script src="../js/jquery/jquery.uniform.min.js"></script>
	<script src="../js/jquery/jquery.placeholder.min.js"></script>
	<script src="../js/init.js"></script>
	<script src="../js/json2.js"></script>
	<script src="../js/var.js"></script>


	<script src="../js/widgets.js"></script>
	<script src="../js/dashboard.js"></script>

	<script>
		$(document).ready(
				function() {

					reload();
					vlidateSid();
					Dashboard.init();


					setTimeout('getUnreadMsgCount()', 1000);

					$("#useruser").after(parent.userInfo.user.nickname);
					$('.accordion_container').accordion();

					$('.tab_container').tabs();

					$('#datepicker').datepicker();

					$("#progressbar").progressbar({
						value : 59
					});

					$('#slider-range').slider(
							{
								range : true,
								min : 0,
								max : 500,
								values : [ 75, 300 ],
								slide : function(event, ui) {
									$("#amount").val(
											"$" + ui.values[0] + " - $"
													+ ui.values[1]);
								}
							});

					$("#amount").val(
							"$" + $("#slider-range").slider("values", 0)
									+ " - $"
									+ $("#slider-range").slider("values", 1));
					
					
		

				});
		
		
		

		function reload(data) {
			if (data == null) {
				data = parent.getFriendList(reload);
			} else {
				$("#teamSelector").empty();
				$("#contentLeft").empty();
				$
						.each(
								data.teams,
								function(k, v) {
									$("#teamSelector").append(
											$("<option value="+v.id+" >"
													+ v.name + "</option >"));
									team = $("<h3>");
									teama = $("<a>");
									//team.addClass("accordion_panel");
									team.append(teama)
									teama.attr("href", "#");
									teama.attr("id", "team_" + v.id);
									teama.text(v.name);
									userList = $("<div>");
									
									//userList.addClass("accordion_content");
									$
											.each(
													v.users,
													function(kk, vv) {
														user = $('<div class="xgrid" >');
														nickName = $("<div>");
														user.append(nickName);
														nickName.addClass("x5");

														nickName
																.text(vv.nickName);
														user.attr("id", "user_" + vv.id);
														btns = $('<div class="x4">');
														user.append(btns);
														startTalk = $('<button class="btn btn-orange">');
														startTalk.text('发起会话');
														startTalk
																.click(function() {
																	parent
																			.openDialog(
																					vv.id,
																					vv.nickName,
																					null);
																	parent
																			.go('index.html');
																});
														btns.append(startTalk);
														btns
																.append($('<button class="btn btn-orange">删除好友</button>'))

														userList.append(user);
													});
									$("#contentLeft").append(team);
									$("#contentLeft").append(userList);

								});
				$('h3').next().hide();
				$('h3').click(function(){
					$(this).next().toggle('slow');
				});
			}

		}

		function getUnreadMsgCount() {
			count = parent.unReadMsgBox.length;
			if (count == 0) {
				$("#unreadMsgTip").text('没有未读的消息');
			} else {
				$("#unreadMsgTip").text('您有' + count + '条新消息');
			}
			setTimeout('getUnreadMsgCount()', 1000);
		}

		function addTeam() {
			teamname = $("#teamInput").val();
			if (name == '') {
				return false;
			}

			$.post('../' + getUrl(), {
				'service' : 'createTeam',
				'sessionId' : parent.sid,
				'name' : teamname
			}, function(data) {
				jo = JSON.parse(data);
				if (jo.state == 'success') {
					reload();
				} else {
					parent.errorDisposer(jo.error);
				}
			});

		}
	</script>

</body>

</html>